package com.ljh.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ljh.pojo.Singer;
import com.ljh.vo.SexVo;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SingerMapper extends BaseMapper<Singer> {

    @Delete("delete from singer where singerId = #{singerId}")
    public void deleteSingerById(Integer singerId);

    @Select("select * from singer where singerId = #{singerId}")
    public Singer findSingerById(Integer singerId);

    @Update("update singer set singerName=#{singer.singerName},singerSex=#{singer.singerSex},singerIndroduce=#{singer.singerIndroduce},create_time=#{singer.create_time},singerAddress=#{singer.singerAddress} where singerId = #{singer.singerId}")
    public Integer updateSingerById(@Param("singer") Singer singer);

    @Update("update singer set singerPhoto = #{singerPhoto} where singerId = #{singerId}")
    public void UpdatePersonPhoto(String singerPhoto,Integer singerId);

    @Insert("insert into singer (singerName,singerSex,create_time,singerAddress,singerIndroduce) values (#{singer.singerName},#{singer.singerSex},#{singer.create_time},#{singer.singerAddress},#{singer.singerIndroduce})")
    public void insertSinger(@Param("singer") Singer singer);

    @Select("select * from singer where singerName like #{singerName}")
    public List<Singer> findSingerByName(String singerName);

    @Select("SELECT singerSex as name ,count(*) as value from singer group by singerSex")
    public List<SexVo> findSingerSex();
}
